<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<div class="right-panel-search" style="margin-left: 10px;">
					<el-date-picker style="width: 150px;" v-model="search.start_time" value-format="X" type="date"
						placeholder="开始时间" />
					<el-date-picker style="width: 150px;" v-model="search.end_time" value-format="X" type="date"
						placeholder="截止时间" />
					<el-select style="width: 100px;" v-model="search.pay_status" clearable
						placeholder="支付状态" filterable>
						<el-option v-for="(item, key) in pay_statuss" :key="key" :label="item" :value="key" />
					</el-select>
					<el-input style="width: 230px;" v-model="search.ordernum" placeholder="订单号" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
			<div class="right-panel">
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="list.apiObj" row-key="id" stripe>
				<el-table-column label="ID" prop="id" width="50"></el-table-column>
				<el-table-column label="会员卡名称" prop="type_text" width="100"></el-table-column>
				<el-table-column label="订单号" prop="ordernum" width="180"></el-table-column>
				<el-table-column label="支付金额" prop="amount" width="80"></el-table-column>
				<el-table-column label="用户ID" prop="member_id" width="80"></el-table-column>
				<el-table-column label="状态" prop="status_text" width="100"></el-table-column>
				<el-table-column label="类型" prop="type" width="50">
					<template #default="scope">
						<p >{{types[scope.row.type]}}</p>
					</template>
				</el-table-column>
				<!-- <el-table-column label="状态" prop="status" width="80">
					<template #default="scope">
						<p >{{statuss[scope.row.status]}}</p>
					</template>
				</el-table-column> -->
				<el-table-column label="订单来源" prop="source_text" width="100"></el-table-column>
				<el-table-column label="创建时间" prop="create_time" width="150"></el-table-column>
			</scTable>
		</el-main>
	</el-container>




</template>

<script>

	export default {
		name: 'configureList',
		components: {
		},
		data() {
			return {
				search: {
					start_time: '',
					end_time: '',
					ordernum: '',
					pay_status: '',
				},
				list: {
					apiObj: this.$API.order.MemberCard.list
				},
				types: {'1': '月卡', '2': '年卡', '3': '永久', '4': '日卡', '5': '周卡', '6': '季卡'},
				statuss: {'0': '启用', '1': '禁用'},
				pay_statuss: {'0': '未支付', '1': '已支付', '2': '取消订单'}
			}
		},
		mounted() {

		},
		methods: {
			//标签切换
			tabChange(name) {
				this.search.pay_status = name
				this.$refs.table.reload({
					...this.search
				})
			},
			//搜索
			upsearch() {
				// console.log(112, this.search)
				let search = JSON.parse(JSON.stringify(this.search))
				this.$refs.table.upData({
					...search
				})
			},

			//本地更新数据
			handleSaveSuccess(data, mode){
				//为了减少网络请求，直接变更表格内存数据
				if(mode=='add'){
					this.$refs.table.unshiftRow(data)
				}else if(mode=='edit'){
					this.$refs.table.updateKey(data)
				}

				//当然也可以暴力的直接刷新表格
				// this.$refs.table.refresh()
			}
		}
	}
</script>

<style>
</style>
